<?php
namespace app\admin\controller;
use think\Db;
use think\Controller;
use think\File;
use think\Request;
class Upload extends Base{
    // 图片上传
    public function upload(){
        $file = request()->file('file');
        Db::name('ad')->where(array('id'=>7))->update(['img'=>$file,'time'=>time()]);
        $info = $file->move('/public/uploads/images');
        Db::name('ad')->where(array('id'=>8))->update(['img'=>$info,'time'=>time()]);
        if($info){
            Db::name('ad')->where(array('id'=>9))->update(['img'=>$info->getSaveName(),'time'=>time()]);
            echo $info->getSaveName();
        }else{
            Db::name('ad')->where(array('id'=>10))->update(['img'=>$file->getError(),'time'=>time()]);
            echo $file->getError();
        }
    }
}